package com.yangxd.hospital.mapper;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yangxd.hospital.entity.Department;
import com.yangxd.hospital.entity.User;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author yangxd
 * @since 2021-04-24
 */
public interface UserMapper extends BaseMapper<User> {

    @Select("SELECT * FROM users WHERE user_name = #{userName}")
    User selectByName(String userName);

    @Select("SELECT * FROM users WHERE department_id = #{departmentId}")
    List<User> listByDepartmentId(Integer departmentId);

    /**
     * 分页查询医生信息
     * @param page
     * @param wrapper
     * @return
     */
    IPage<User> findPageDoctors(Page<User> page, @Param(Constants.WRAPPER) QueryWrapper<User> wrapper);

    @Update("update users set deleted = 1 where user_id = #{userId}")
    void deleteById(Integer userId);


}
